package com.sihan.framework.etm.controller;

import com.framework.model.ApiResult;
import com.sihan.framework.etm.service.CodeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "码表管理")
@RestController
@RequestMapping("/common/v0/code")
public class CodeController {
	
	@Autowired
	private CodeService codeService;
	  
	@ApiOperation("根据码表类型查询码表值")
	@GetMapping("/list")
	@ApiImplicitParams({
	      @ApiImplicitParam(name = "codeType", value = "码表类型(deviceType-设备类型)", dataType = "string", paramType = "query", required = true)
	  })
	public ApiResult<?> getCodeStdList(String codeType) {
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		result.addAll(codeService.getCodeByType(codeType));
		return ApiResult.success(result);
	}
}
